package com.financing.wap.service.impl;


import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import com.financing.wap.common.CommonConstantUtil.CommonStatus;
import com.financing.wap.dao.IDstFileRecordDao;
import com.financing.wap.dto.DstFileRecordDTO;
import com.financing.wap.service.IDstFileRecordService;
import com.financing.wap.util.DTOdateSetUtil;
/**
 * dst_file_record  
 * 文件记录表 业务访问层实现类
 * @author huqiyun
 *
 */
 
@Service("dstFileRecordService")
public class DstFileRecordServiceImpl implements IDstFileRecordService{

	@Autowired
	private IDstFileRecordDao dstFileRecordDao;

	@Override
	public int insert(DstFileRecordDTO dstFileRecord) throws SQLException {
		DTOdateSetUtil.setCreateInfo(dstFileRecord);
		DTOdateSetUtil.setUpdateInfo(dstFileRecord);
		dstFileRecord.setDeleteTag(CommonStatus.DELETE_TAG_NORMAL);
		return dstFileRecordDao.insert(dstFileRecord);
	}

	@Override
	public void update(DstFileRecordDTO dstFileRecord) throws SQLException {
		DTOdateSetUtil.setUpdateInfo(dstFileRecord);
		dstFileRecordDao.update(dstFileRecord);
	}

	@Override
	public void updateForce(DstFileRecordDTO dstFileRecord) throws SQLException {
		DTOdateSetUtil.setUpdateInfo(dstFileRecord);
		dstFileRecordDao.updateForce(dstFileRecord);
	}

	@Override
	public void delete(Integer id) throws SQLException {
		dstFileRecordDao.delete(id);
	}
	
	@Override
	public List<DstFileRecordDTO> queryList(DstFileRecordDTO dstFileRecord) throws SQLException {
		return dstFileRecordDao.queryList(dstFileRecord);
	}

	@Override
	public int queryListCount(DstFileRecordDTO dstFileRecord) throws SQLException {
		return dstFileRecordDao.queryListCount(dstFileRecord);
	}

	@Override
	public DstFileRecordDTO loadById(Integer id) throws SQLException {
		return dstFileRecordDao.loadById(id);
	}
 	@Override
	public DstFileRecordDTO queryListGetFirst(DstFileRecordDTO dstFileRecord)
			throws SQLException {
		 List<DstFileRecordDTO> queryList = queryList(dstFileRecord);
		 if(queryList==null||queryList.size()==0){
			 return new DstFileRecordDTO();
		 }
		 return queryList.get(0);
	}
}
